package com.ttl.bc.master.itemunit;

import java.util.ArrayList;
import java.util.List;

import hibernate.util.HibernateUtil;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.ttl.common.db.ADAO;

public class BCItemUnitDAO extends ADAO {

	@SuppressWarnings("unchecked")
	public List findAll() {
		List result = new ArrayList();
		Session session = null;

		try {
			SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
			session = sessionFactory.openSession();
			
			session.beginTransaction();			
			Query q = session.createQuery("FROM BCItemUnitBean  ORDER BY name");
			result = q.list();
			
			session.getTransaction().commit();						
			
		}catch(Exception e) {			
			System.out.println(e.toString());
		}finally {
			session.close();
		}
		
		return result;		
	}
}
